#include <reg52.h>
#include "serial.h"
#define uint unsigned int
#define uchar unsigned char
sbit led=P1^6;
sbit analog=P2^3;
uchar ad_c,fsc,ad2;
uint ad_i;
void delay20us(void);
void delay(uint z);
uchar code smgsz[]={
0xC0,0xf9,0xA4,0xB0,
0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,
0xC6,0xA1,0x86,0x8E};
void main()
{
	InitUART();
	sendChar(0xFE);
	while(1)
	{
		analog=1;
		while(!analog)
		{
			ad_i++;
			delay20us();
		}
		analog=0;
		led=1;
		ad_c=ad_i-0x8D;
		ad2=ad_c/2;
		for(fsc=0;fsc<=ad2;fsc++)
		{
			sendChar(0x20);
		}
		if(ad_c%2==0)
			sendChar(0x4C);
		else
			sendChar(0x4A);
		sendChar(0x0A);
		ad_c=0;
		ad_i=0;
		for(fsc=0;fsc<6;fsc++)
			delay(60000);
		delay(30000);
		led=0;
	}
}
void delay20us(void)   //?? -0.188679245283us
{
    unsigned char a,b;
    for(b=7;b>0;b--)
        for(a=2;a>0;a--);
}
void delay(uint z)
{
	uint x,y;
	for(x=z;x>0;x--)
		for(y=110;y>0;y--);
}